﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<ThietBiSo.LinQDB.TinTuc>" %>

<%@ Import Namespace="ThietBiSo.LinQDB" %>
<%@ Import Namespace="ThietBiSo.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Website - bảng điều khiển
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        function popupURL(url, width, height) {
            var left = (screen.width - width) / 2;
            var top = (screen.height - height) / 2;
            window.open(url, 'NapCoin', 'left=' + left + 'px,top=' + top + 'px,width=' + width + 'px,height=' + height + 'px,location=no,scrollbars=yes,toolbar=no,resizable=yes,')
        }
        function getUrlVars() {
            var vars = {};
            var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
                vars[key] = value;
            });
            return vars;
        }

        $().ready(function () {
            // var first = getUrlVars()["cbNhom"];

            $("#btnAdd").click(function () {
//                if (checkForm()) {
                    location.href = '<%=Url.Action("Create","tintuc")%>';
                //}
            });

            $("#cbNhom").change(function () {
                location.href = '<%=Url.Action("tintuc","tintuc")%>' + "?cbNhom=" + $("#cbNhom").val();
            });


        });

        function checkForm() {
            var flag = true;
            var F = document.forms[0];
            var cbNhom = document.getElementById("cbNhom").value;

            if (cbNhom == null || cbNhom == 0 || cbNhom == "") {
                alert("Chưa chọn danh mục");
                F.cbNhom.focus();
                flag = false;

            }

            return flag;
        }
      
      
    </script>
    <%
        MLoaiTinTuc mltt = new MLoaiTinTuc();
        var vloaitintuc = mltt.FindAll();


        string maloaitt = Request.QueryString["cbNhom"];
        MTinTuc mtt = new MTinTuc();
    
       
            
    %>
    <table width="100%" cellpadding="2" cellspacing="0" border="0">
        <tr>
            <td>
                <table width="100%">
                    <tr>
                        <td align="left">
                          
                            <input type="button" value="Thêm Tin Tức" id="btnAdd" />
                            
                        </td>
                        <td align="right">
                            <%: Html.ActionLink("Quay lại", "quantri", "Admin", null, new { @class = "" })%>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
       
        <tr>
            <td colspan="2">
                <table id="bang_admin" class="tbl colorize" width="100%" border="0">
                    <tbody>
                        <tr>
                            <th align="center" width="20px">
                                TT
                            </th>
                            <th align="center" width="50">
                                Hinh
                            </th>
                            <th>
                                Tiêu đề
                            </th>
                            <th align="center" width="100">
                                Xuất bản
                            </th>
                            <th align="center" width="100">
                                Trang chủ
                            </th>
                            <th align="right" width="30">
                                Xóa
                            </th>
                        </tr>
                    </tbody>
                    <tbody>
                        <% foreach (TinTuc tt in (List<TinTuc>)ViewData["tintucs"])
                           {               
                        %>
                        <tr class="tb_hienthi">
                            <td align="center" valign="middle">
                                <input type="text" disabled="disabled" style="width: 20px" autocomplete="off" class="orderbox"
                                    value="<%:tt.ThuTu %>" maxlength="4" id="thutu" />&nbsp;
                            </td>
                            <td align="center" valign="middle">
                                <a href="<%=Url.Action("Edit","tintuc", new { id = tt.MaTinTuc} ) %>">
                                    <%if (tt.UrlHinh == "" || tt.UrlHinh == null || tt.UrlHinh == "noImage")
                                      {%>
                                    <img src="<%:Url.Content("~/Content/images/nophoto.gif")%>" alt="" width="100px"
                                        height="60px" />
                                    <%}
                                      else
                                      { %>
                                    <img src="<%: tt.UrlHinh%>" alt="" width="100px;" height="60px;" />
                                    <%} %>
                                </a>
                            </td>
                            <td align="left" valign="middle">
                                <a href="<%=Url.Action("Edit","TinTuc", new { id = tt.MaTinTuc } ) %>">
                                    <%:tt.TieuDe%>
                                </a>
                            </td>
                            <td align="center">
                                <%if (tt.TinMoi == false)
                                  {
                                %>
                                <a href="javascript:tintuc_tinmoi(<%:tt.MaTinTuc%>);">
                                    <input type="checkbox" />
                                </a>
                                <%}
                                  else
                                  {%>
                                <a href="javascript:tintuc_tinmoi(<%:tt.MaTinTuc%>);">
                                    <input type="checkbox" checked="checked" /></a>
                                <%} %>
                            </td>
                            <td align="center">
                                <%if (tt.HienThi == false)
                                  {
                                %>
                                <a href="javascript:tintuc_HienThi(<%:tt.MaTinTuc%>);">
                                    <input type="checkbox" />
                                </a>
                                <%}
                                  else
                                  {%>
                                <a href="javascript:tintuc_HienThi(<%:tt.MaTinTuc%>);">
                                    <input type="checkbox" checked="checked" /></a>
                                <%} %>
                            </td>
                            <td align="center">
                                <a href="javascript:TinTuc_Delete(<%:tt.MaTinTuc %>);">
                                    <img src="../../Content/imagesAdmin/images/pic_trash.gif" alt="" /></a>
                            </td>
                        </tr>
                        <% } %>
                    </tbody>
                </table>
            </td>
        </tr>
        <tr>
            <td style="text-align: center; clear: both; width: 100%; padding: 20px 0 10px 0;">
                <% if ((string)ViewData["pageLinks"] != "")
                   { %>
                <%= ViewData["pageLinks"]%>
                <% } %>Tổng: <strong>
                    <%= ViewData["total"]%></strong>
            </td>
        </tr>
     
    </table>
</asp:Content>
